import {ref,onMounted ,onBeforeUnmount} from 'vue'

export default function getMouse(){
    let x=ref(0); //x坐标
    let y=ref(0);//y坐标

    let getPosition=(e:MouseEvent)=>{
        x.value=e.clientX;
        y.value=e.clientY;
    }
    onMounted(()=>{ //绑定鼠标移动事件
        console.log("你不好")
        document.addEventListener("mousemove",getPosition)
    })
    onBeforeUnmount(()=>{   
          // 移除鼠标移动事件
        document.removeEventListener("mousemove",getPosition);
    })
    return {
      x,
      y
    }

}